# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=xapian-omega
pkgver=1.4.16
pkgrel=0
pkgdesc="Indexers and CGI search frontend for Xapian"
url="http://www.xapian.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="$depends_dev xapian-core-dev perl-dev pcre-dev zlib-dev file-dev"
subpackages="$pkgname-doc"
source="http://oligarchy.co.uk/xapian/${pkgver}/$pkgname-$pkgver.tar.xz
disable-omegatest-faketime-ismissing.patch"
builddir="$srcdir"/$pkgname-$pkgver

prepare() {
	default_prepare
	sed -i -e "s/std::getchar/getchar/g" urldecode.h
	sed -i -e "s/template_dir.*/template_dir \/usr\/share\/omega\/templates/g" omega.conf
}

build() {
	./configure XAPIAN_CONFIG=/usr/bin/xapian-config \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/$pkgname \
		--enable-static=no
	make
}

check() {
	make check
}

package() {
	local f
	make DESTDIR=$pkgdir install
	install -Dm755 omega.conf "$pkgdir"/etc/$pkgname/omega.conf
	mkdir -p "$pkgdir"/var/log/omega
	mkdir -p "$pkgdir"/var/lib/omega/cdb
	mkdir -p "$pkgdir"/var/lib/omega/data
	for f in templates images; do
    		install -d "$pkgdir"/usr/share/omega/$f && cp -ar $f/* "$pkgdir"/usr/share/omega/$f ;
	done
}

sha512sums="7f8c3d4e372c49f89e28da999ee49f0754052a339bbc4492b50f8134cf29b2c433ddae9e58ef3a2468898b711b4510ea87687a247ce21e83eba2f8daaa2910c4  xapian-omega-1.4.16.tar.xz
bc04b93a178c45438c34269e28638bebe16ebfcfb12959fb101ea16f47cf514ba2330c9b9ac45dc4660d55acad936ff1bfbdcafcc7acf115cd85de077d096cea  disable-omegatest-faketime-ismissing.patch"
